<?php
$name = isset($_POST['name']) ? trim($_POST['name']) : '';

$result = ['result'=>false, 'msg' => '', 'data' => null];

if(empty($name))
{
    $result['msg'] = '城市名称为空，无法查询';

    echo json_encode($result);
    exit;
}


$url = "https://query.asilu.com/weather/baidu/?city=$name";

$content = file_get_contents($url);

$result['result'] = true;
$result['msg'] = '查询成功';
$result['data'] = json_decode($content, true);

echo json_encode($result);
exit;

?>